/*
 * Copyright (c) 2011 Toni Spets <toni.spets@iki.fi>
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#ifndef _HTTP_H_
#define _HTTP_H_

#include <windows.h>
#include <stdbool.h>
#include <stdio.h>
#include <wininet.h>

typedef struct
{
    void *buf;
    size_t bufpos;
    size_t bufsiz;
} download;

typedef bool (*HTTP_CALLBACK)(void *buf, size_t len, size_t file_pos, size_t file_size, void *context);

bool http_init();
bool http_release();
bool http_get(const char *url, HTTP_CALLBACK cb, void *context);
bool http_write_mem(void *buf, size_t size, size_t file_pos, size_t file_size, download *dl);
int http_download_mem(const char *url, void *buf, size_t *bufsiz);
int http_download_file(const char *url, const char *path);

#endif
